<%@ page import="com.hzit.dao.EmpDao" %>
<%@ page import="com.hzit.bean.Emp" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2020/10/13
  Time: 13:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<%--set--%>
<c:set var="username" value="page_zhagnsan"></c:set>
<c:set var="username" value="request_zhagnsan" scope="request"></c:set>
<c:set var="username" value="seesion_zhagnsan" scope="session"></c:set>
<c:set var="username" value="application_zhagnsan" scope="application"></c:set>

<%--删除指定域 域数据--%>
<c:remove var="username"/>

<c:out value="${username}" default="用户名"/>
<c:out value="${requestScope.username}" default="用户名"/>
<c:out value="${sessionScope.username}" default="用户名"/>
<c:out value="${applicationScope.username}" default="用户名"/>


<%--if--%>
<c:if test="${not empty username}">
    <h1>${username}</h1>
</c:if>
<c:if test="${empty username}">
    <h1>暂时没有数据</h1>
</c:if>

<c:set var="score" value="39"></c:set>

<c:choose>
    <c:when test="${score>=90}">
        <h1>优秀</h1>
    </c:when>
    <c:when test="${score>=60}">
        <h1>及格</h1>
    </c:when>
    <c:otherwise>
        <h1>不及格，或者异常!</h1>
    </c:otherwise>
</c:choose>

<%--
    for(int i = 0;i<=list.size();i++){

    }

    for(int a:list){

    }

--%>

<%

    EmpDao empDao = new EmpDao();
    List<Emp> empList = empDao.findAll();

    request.setAttribute("empList", empList);
%>

<%--
    items:需要遍历的集合或者数组
    var:定义变量
    begin:开始值
    end：结束值
    step:步长，每次增长数量
    varStatus:状态，例如：下标，总数，是否是第一行...
--%>
<c:forEach var="i" begin="0" end="${empList.size()}" step="1" varStatus="vs">

    <p>${empList[i]}</p>

</c:forEach>

<hr/>

<c:forEach var="emp" items="${empList}" varStatus="vs">
    <p> ${vs.index+1} --> ${emp}</p>
</c:forEach>

<hr/>

<%
    Date date = new Date();
    pageContext.setAttribute("d", date);
%>
<p>${d}</p>
<fmt:formatDate value="${d }" pattern="yyyy-MM-dd HH:mm:ss"/>

<p></p>
<%
    double d1 = 3.5;
    double d2 = 4.4;
    double d3 = 5.128456;
    double d4 = 5.1254;
    pageContext.setAttribute("d1", d1);
    pageContext.setAttribute("d2", d2);
    pageContext.setAttribute("d3", d3);
    pageContext.setAttribute("d4", d4);
%>

<fmt:formatNumber value="${d1 }" pattern="0.00"/><br/>
<fmt:formatNumber value="${d2 }" pattern="#.##"/>
<fmt:formatNumber value="${d3 }" pattern="0.00"/><br/>
<fmt:formatNumber value="${d4 }" pattern="#.##"/>


<%--重定向--%>
<c:redirect url="el.jsp"></c:redirect>
<%--<jsp:forward page="">请求转发</jsp:forward>--%>
</body>
</html>
